<?php
/**
* @version		1.1
* @package		Taxi Booking
* @copyright	Copyright (C) 2011 KANEV.CO.UK All rights reserved.
* @license		GNU/GPL, see license.txt
* Taxi Booking is open source software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*GNU General Public License for more details.
*You should have received a copy of the GNU General Public License
*along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
 
function TaxiBookingBuildRoute(&$query)
{

	$segments = array();

	if(isset($query['view']))
	{
		if(empty($query['Itemid'])) {
			$segments[] = $query['view'];
		}
		
		if($query['view'] == 'confirm') {
			$segments[] = $query['view'];
		}
		
		if($query['view'] == 'summary') {
			$segments[] = $query['view'];
		}
                
                if($query['view'] == 'thanks') {
			$segments[] = $query['view'];
		}
                
                if($query['view'] == 'orders') {
			$segments[] = $query['view'];
		}
                
                if($query['view'] == 'order') {
			$segments[] = $query['view'];
		}
                
                if($query['view'] == 'settings') {
			$segments[] = $query['view'];
		}

		unset($query['view']);
	};

	if(isset($query['cid']))
	{
		$segments[] = $query['cid'];
		unset($query['cid']);
	};

	if(isset($query['id']))
	{
		$segments[] = $query['id'];
		unset($query['id']);
	};

	return $segments;
}

function TaxiBookingParseRoute($segments)
{
	$vars = array();

	// Count route segments
	$count = count($segments);
	
	if($segments[0] == 'confirm') {
		$vars['view'] = 'confirm';
		return $vars;
	}
        
        if($segments[0] == 'summary') {
		$vars['view'] = 'summary';
		return $vars;
	}
        
        if($segments[0] == 'thanks') {
		$vars['view'] = 'thanks';
		return $vars;
	}
        
        if($segments[0] == 'settings') {
		$vars['view'] = 'settings';
		return $vars;
	}
        
        if($segments[0] == 'orders') {
		$vars['view'] = 'orders';
		return $vars;
	}
        
	if($segments[0] == 'order') {
		$vars['view'] = 'order';
		$vars['cid'] = $segments[1];
		return $vars;
	}
 
	if ($count == 0) {
		$vars['view'] = 'taxibooking';
	}
	
	return $vars;
}
?>